{extend name="../../../view/public/base" /}
{block name="css"}
<style>

    /*.select-test{position: absolute;max-height: 500px;height: 350px;overflow: auto;width: 100%;z-index: 123;display: none;border:1px solid silver;top: 42px;}*/
    /*.layui-show{display: block!important;}*/
    body {
        padding: 20px; background-color: #F2F2F2;
    }
    /*.layui-input-block{*/
        /*height:auto;*/
        /*overflow:visible;*/
        /*text-overflow:inherit;*/
        /*!*text-overflow:none;*!*/
    /*}*/
    .layui-form-pane .layui-form-label {
        font-size: 10px;
    }
    .layui-elip, .layui-form-checkbox span, .layui-form-pane .layui-form-label {
         text-overflow:clip;
        white-space: nowrap;
    }
   /*.layui-input-block .layui-input{*/
        /*display: block;*/
        /*width: 80%;*/
        /*padding-left: 15px;*/
        /*padding-right: 15px;*/
    /*}*/
    /*.layui-tab-item{*/
        /*width: 100%;*/
        /*height: 800px;*/
    /*}*/
</style>
<link rel="stylesheet" href="/layui/lib/font-awesome-4.7.0/css/font-awesome.min.css" media="all">
<!--<link rel="stylesheet" href="/layui/js/lay-module/upload/cropper/publish.css" media="all">-->

{/block}
{block name="body"}
<form class="layui-form layui-form-pane" id="form">


        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-header">配置设置</div>
                    <div class="layui-card-body">

                        <div class="layui-tab layui-tab-card" lay-filter="docDemoTabBrief">
                            <ul class="layui-tab-title"  >
                                {volist name="show" id="vo" key="k"}
                                {eq name="k" value="1"}
                                <li class="layui-this"><i class="{$vo.icon}"></i>&nbsp&nbsp{$vo.title}</li>
                                {else/}
                                <li><i class="{$vo.icon}"></i>&nbsp&nbsp{$vo.title}</li>
                                {/eq}
                                {/volist}
                            </ul>

                            <div class="layui-tab-content" >

                                {volist name="show" id="vo" key="k"}
                                <div class='layui-tab-item {eq name="k" value="1"}layui-show{/eq}'>
                                    {if condition="($vo.desc!=null) && ($vo.desc!='') "}
                                    <blockquote class="layui-elem-quote">{$vo.desc|RAW}</blockquote>
                                    {/if}
                                    <table class="layui-table" >
                                        <colgroup>
                                            <col  width="600">
                                            <col>

                                        </colgroup>
                                        <thead>
                                        <tr >
                                            <th style="text-align: center">配置值</th>
                                            <th style="text-align: center">配置字段</th>

                                        </tr>
                                        </thead>
                                    </table>
                                   <br>

                                    {volist name="vo.config_list" id="config" key="i"}


                                        <!--生成表单   start-->
                                    {switch name="config.type"}
                                    {case value="text"}
                                    <!--普通文本框-->

                                        {switch name="config.input_type"}
                                        {case value="text"}
                                         <!--普通文本框-->
                                        <div class="layui-form-item">
                                            <div class="layui-col-md7">
                                                <label class="layui-form-label" >{$config.info}</label>
                                                <div class="layui-input-block" id="{$config.config_name}">
                                                    <input  type="text" name="{$config.config_name}"
                                                            autocomplete="off" placeholder="{$config.info}" class="layui-input"
                                                            value="{$config.value|default=''}">
                                                </div>
                                            </div>
                                            <div class="layui-col-md5">
                                                <div class="layui-input-block" >
                                                    {$config.label_name}
                                                </div>
                                            </div>


                                        </div>
                                          <script>

                                              layui.use(['jquery','layer'],function() {
                                                  var $ = layui.jquery,
                                                  layer = layui.layer;
                                                  $(function(){
                                                      var tips;
                                                      $('#{$config.config_name}').on({
                                                          mouseenter:function(){
                                                              var that = this;
                                                              tips =layer.tips("{$config.desc}",that,{tips:[1,'#5FB878'],time:0, area: 'auto'});
                                                          },
                                                          mouseleave:function(){
                                                              layer.close(tips);
                                                          }
                                                      });
                                                  })

                                              })

                                         </script>


                                        {/case}
                                        {case value="number"}
                                         <!--数字文本框-->
                                         <div class="layui-form-item">
                                             <div class="layui-col-md7">
                                                 <label class="layui-form-label" >{$config.info}</label>
                                                 <div class="layui-input-block" id="{$config.config_name}">
                                                     <input  type="number" name="{$config.config_name}"
                                                             autocomplete="off" placeholder="{$config.info}" class="layui-input"
                                                             oninput = "value=value.replace(/[^\d]/g,'')"
                                                             value="{$config.value|default=''}">
                                                 </div>

                                             </div>
                                             <div class="layui-col-md5">
                                                 <div class="layui-input-block" >
                                                     {$config.label_name}
                                                 </div>
                                             </div>

                                         </div>
                                       <script>

                                        layui.use(['jquery','layer'],function() {
                                            var $ = layui.jquery,
                                                layer = layui.layer;
                                            $(function(){
                                                var tips;
                                                $('#{$config.config_name}').on({
                                                    mouseenter:function(){
                                                        var that = this;
                                                        tips =layer.tips("{$config.desc}",that,{tips:[1,'#5FB878'],time:0,area: 'auto'});
                                                    },
                                                    mouseleave:function(){
                                                        layer.close(tips);
                                                    }
                                                });
                                            })

                                        })

                                        </script>



                                        {/case}
                                        {case value="timestamp"}
                                         <!--日期-->
                                    <div class="layui-form-item">
                                        <div class="layui-col-md7">
                                            <label class="layui-form-label" >{$config.info}</label>
                                            <div class="layui-input-block" id="{$config.config_name}">
                                                <input  type="text" name="{$config.config_name}"
                                                        id="time{$config.config_name}"

                                                        autocomplete="off" placeholder="{$config.info}" class="layui-input"
                                                >
                                            </div>
                                        </div>
                                        <div class="layui-col-md5">
                                            <div class="layui-input-block" >
                                                {$config.label_name}
                                            </div>
                                        </div>

                                    </div>
                                    <script>

                                        layui.use(['jquery','layer', 'laydate','util'],function() {
                                            var $ = layui.jquery,
                                                layer = layui.layer
                                                ,util = layui.util
                                               ,laydate = layui.laydate;
                                            $(function(){
                                                var tips;
                                                $('#{$config.config_name}').on({
                                                    mouseenter:function(){
                                                        var that = this;
                                                        tips =layer.tips("{$config.desc}",that,{tips:[1,'#5FB878'],time:0,area: 'auto'});
                                                    },
                                                    mouseleave:function(){
                                                        layer.close(tips);
                                                    }
                                                });
                                            })

                                            //日期时间选择器
                                            laydate.render({
                                                elem: '#time{$config.config_name}'
                                                ,value: new Date(parseInt('{$config.value? $config.value : 0}')*1000)
                                                ,isInitValue: true
                                                ,type: 'datetime'
                                            });
                                        })

                                    </script>


                                        {/case}
                                        {case value="color"}
                                         <!--颜色选择器-->
                                    <div class="layui-form-item">
                                        <div class="layui-col-md7">
                                            <label class="layui-form-label" >{$config.info}</label>
                                            <div class="layui-input-block" id="{$config.config_name}">
                                                <div id="color{$config.config_name}" style="margin-left: 30px;"></div>
                                                <input  type="hidden" name="{$config.config_name}"
                                                        id="input{$config.config_name}"
                                                        value="{$config.value? $config.value : ''}"
                                                >
                                            </div>
                                        </div>
                                        <div class="layui-col-md5">
                                            <div class="layui-input-block" >
                                                {$config.label_name}
                                            </div>
                                        </div>

                                    </div>
                                    <script>

                                        layui.use(['jquery','layer','colorpicker'],function() {
                                            var $ = layui.jquery,
                                                layer = layui.layer
                                        ,colorpicker = layui.colorpicker;
                                            $(function(){
                                                var tips;
                                                $('#{$config.config_name}').on({
                                                    mouseenter:function(){
                                                        var that = this;
                                                        tips =layer.tips("{$config.desc}",that,{tips:[1,'#5FB878'],time:0,area: 'auto'});
                                                    },
                                                    mouseleave:function(){
                                                        layer.close(tips);
                                                    }
                                                });
                                            })


                                            colorpicker.render({ //无初始色值时
                                                elem: '#color{$config.config_name}'
                                                ,alpha: true
                                                ,format: 'rgb'
                                                ,color: "{$config.value? $config.value : '#000'}" //默认值
                                                ,done: function(color){
                                                      //选色回调
                                                    $('#input{$config.config_name}').val(color);
                                                }
                                            });
                                        })

                                    </script>




                                        {/case}
                                        {case value="float"}
                                          <!--浮点数-->
                                    <div class="layui-form-item">
                                        <div class="layui-col-md7">
                                            <label class="layui-form-label" >{$config.info}</label>
                                            <div class="layui-input-block" id="{$config.config_name}">
                                                <input  type="number" name="{$config.config_name}"
                                                        step="0.001"
                                                        autocomplete="off" placeholder="{$config.info}" class="layui-input"
                                                        value="{$config.value|default=''}">
                                            </div>
                                        </div>
                                        <div class="layui-col-md5">
                                            <div class="layui-input-block" >
                                                {$config.label_name}
                                            </div>
                                        </div>

                                    </div>
                                    <script>

                                        layui.use(['jquery','layer'],function() {
                                            var $ = layui.jquery,
                                                layer = layui.layer;
                                            $(function(){
                                                var tips;
                                                $('#{$config.config_name}').on({
                                                    mouseenter:function(){
                                                        var that = this;
                                                        tips =layer.tips("{$config.desc}",that,{tips:[1,'#5FB878'],time:0,area: 'auto'});
                                                    },
                                                    mouseleave:function(){
                                                        layer.close(tips);
                                                    }
                                                });
                                            })

                                        })

                                    </script>
                                        {/case}
                                        {/switch}

                                    {/case}
                                    {case value="textarea"}
                                    <!--多行文本框-->

                                    <div class="layui-form-item">
                                        <div class="layui-col-md7">
                                            <label class="layui-form-label" >{$config.info}</label>
                                            <div class="layui-input-block" id="{$config.config_name}">
                                            <textarea placeholder="{$config.info}" class="layui-textarea"
                                                      style="height:{$config.high? $config.high.'%' : 'auto'};width: {$config.width? $config.width.'%' : '100%'};"

                                                      lay-verify="value" id ='mtext{$config.config_name}'>{$config.value? $config.value : null}</textarea>
                                                <input type="hidden" id="mtext_input_{$config.config_name}" name="{$config.config_name}" value="{$config.value|default=''}"/>
                                            </div>
                                        </div>
                                        <div class="layui-col-md5">
                                            <div class="layui-input-block" >
                                                {$config.label_name}
                                            </div>
                                        </div>

                                    </div>
                                    <script>

                                        layui.use(['jquery','layer'],function() {
                                            var $ = layui.jquery,
                                                layer = layui.layer;
                                            $(function(){
                                                var tips;
                                                $('#{$config.config_name}').on({
                                                    mouseenter:function(){
                                                        var that = this;
                                                        tips =layer.tips("{$config.desc}",that,{tips:[1,'#5FB878'],time:0,area: 'auto'});
                                                    },
                                                    mouseleave:function(){
                                                        layer.close(tips);
                                                    }
                                                });

                                                //输入框的值改变时触发
                                                $("#mtext{$config.config_name}").on("input",function(e){
                                                    //获取input输入的值
                                                    $('#mtext_input_{$config.config_name}').val(e.delegateTarget.value);
                                                });
                                            })

                                        })

                                    </script>

                                    {/case}
                                    {case value="r_textarea"}
                                    <!--富文本框-->


                                    <div class="layui-form-item">
                                        <div class="layui-col-md7">
                                            <label class="layui-form-label" >{$config.info}</label>
                                            <div class="layui-input-block" id="{$config.config_name}">
                                          <textarea placeholder="{$config.info}" class="layui-textarea"
                                                    lay-verify="value" id ='rtext{$config.config_name}'>{$config.value? $config.value : null}</textarea>
                                                <input type="hidden" id="rtext_input_{$config.config_name}" name="{$config.config_name}" value="{$config.value|default=''}"/>
                                            </div>
                                        </div>
                                        <div class="layui-col-md5">
                                            <div class="layui-input-block" >
                                                {$config.label_name}
                                            </div>
                                        </div>

                                    </div>
                                    <script>
                                        var layedit_index{$config.config_name};
                                        layui.use(['jquery','layer','layedit'],function() {
                                            var $ = layui.jquery,
                                                layedit = layui.layedit,
                                                layer = layui.layer;

                                            layedit.set({
                                                uploadImage: {
                                                    url: "{:Url('/manage/publicCommon/uploadEditor')}?layui=1" //接口url
                                                    ,type: 'post' //默认post
                                                }
                                            });

                                            layedit_index{$config.config_name} = layedit.build('rtext{$config.config_name}',{
                                                height: parseInt("{$config.high? $config.high : 0 }"), //设置编辑器高度
                                               // width: 200
                                            }); //建立编辑器

                                            setInterval(function(){
                                                //console.log(layedit_index);
                                               // console.log('{$config.config_name}');
                                               // console.log(layedit.getContent(layedit_index));
                                                $('#rtext_input_{$config.config_name}').val(r_text_encode(layedit.getContent(layedit_index{$config.config_name})));

                                            },500);

                                            //富文本编辑器改变事件
                                            // $('#LAY_layedit_'+layedit_index).contents().find('body').on('DOMNodeInserted', function () {
                                            //    // layedit.sync(layedit_index);
                                            //     console.log(layedit.getContent(layedit_index));
                                            //
                                            //
                                            // });
                                            $(function(){
                                                var tips;
                                                $('#{$config.config_name}').on({
                                                    mouseenter:function(){
                                                        var that = this;
                                                        tips =layer.tips("{$config.desc}",that,{tips:[1,'#5FB878'],time:0,area: 'auto'});
                                                    },
                                                    mouseleave:function(){
                                                        layer.close(tips);
                                                    }
                                                });
                                                //console.log(layedit_index);

                                            })

                                        })


                                    </script>


                                    {/case}
                                    {case value="radio"}
                                    <!--单选框-->
                                    <div class="layui-form-item">
                                        <div class="layui-col-md7">
                                            <label class="layui-form-label" >{$config.info}</label>
                                            <div class="layui-input-block" id="{$config.config_name}">
                                                {volist name="config.parameter" id="index"}

                                                <input type="radio" name="{$config.config_name}"  value="{$index.value}"  title="{$index.key}" {$config.value==$index.value ?  'checked':'' }  >
                                                {/volist}



                                            </div>
                                        </div>
                                        <div class="layui-col-md5">
                                            <div class="layui-input-block" >
                                                {$config.label_name}
                                            </div>
                                        </div>

                                    </div>
                                    <script>

                                        layui.use(['jquery','layer'],function() {
                                            var $ = layui.jquery,
                                                layer = layui.layer;
                                            $(function(){
                                                var tips;
                                                $('#{$config.config_name}').on({
                                                    mouseenter:function(){
                                                        var that = this;
                                                        tips =layer.tips("{$config.desc}",that,{tips:[1,'#5FB878'],time:0,area: 'auto'});
                                                    },
                                                    mouseleave:function(){
                                                        layer.close(tips);
                                                    }
                                                });
                                            })

                                        })

                                    </script>

                                    {/case}
                                    {case value="checkbox"}
                                    <!--复选框-->
                                    <div class="layui-form-item">
                                        <div class="layui-col-md7">
                                            <label class="layui-form-label" >{$config.info}</label>
                                            <div class="layui-input-block" id="{$config.config_name}">
                                                {volist name="config.parameter" id="index"}

                                                <input type="checkbox" name="{$config.config_name}[]"  value="{$index.value}"  title="{$index.key}" {if condition="strpos($config.value,$index.value)!==false"}checked="" {/if}   >
                                                {/volist}



                                            </div>
                                        </div>
                                        <div class="layui-col-md5">
                                            <div class="layui-input-block" >
                                                {$config.label_name}
                                            </div>
                                        </div>

                                    </div>
                                    <script>

                                        layui.use(['jquery','layer'],function() {
                                            var $ = layui.jquery,
                                                layer = layui.layer;
                                            $(function(){
                                                var tips;
                                                $('#{$config.config_name}').on({
                                                    mouseenter:function(){
                                                        var that = this;
                                                        tips =layer.tips("{$config.desc}",that,{tips:[1,'#5FB878'],time:0,area: 'auto'});
                                                    },
                                                    mouseleave:function(){
                                                        layer.close(tips);
                                                    }
                                                });
                                            })

                                        })

                                    </script>

                                    {/case}
                                    {case value="select"}
                                    <!--下拉框-->
                                    <div class="layui-form-item">
                                                    <div class="layui-col-md7">
                                                        <label class="layui-form-label" >{$config.info}</label>
                                                        <div class="layui-input-block" id="{$config.config_name}">
                                                            <select name="{$config.config_name}"  lay-verify="required" >
                                                                {volist name="config.parameter" id="index"}

                                                                <option value="{$index.value}"  {$config.value==$index.value ?  'selected':'' }  >{$index.key}</option>
                                                    {/volist}
                                                </select>
                                            </div>
                                        </div>
                                        <div class="layui-col-md5">
                                            <div class="layui-input-block" >
                                                {$config.label_name}
                                            </div>
                                        </div>

                                    </div>
                                    <script>

                                        layui.use(['jquery','layer'],function() {
                                            var $ = layui.jquery,
                                                layer = layui.layer;
                                            $(function(){
                                                var tips;
                                                $('#{$config.config_name}').on({
                                                    mouseenter:function(){
                                                        var that = this;
                                                        tips =layer.tips("{$config.desc}",that,{tips:[1,'#5FB878'],time:0,area: 'auto'});
                                                    },
                                                    mouseleave:function(){
                                                        layer.close(tips);
                                                    }
                                                });
                                            })

                                        })

                                    </script>

                                    {/case}
                                    {case value="upload"}
                                    <!--上传-->

                                       {switch name="config.upload_type"}
                                           {case value="1"}
                                            <!--单图-->
                                    <div class="layui-form-item">
                                        <div class="layui-col-md7">
                                            <label class="layui-form-label" >{$config.info}</label>
                                            <div class="layui-input-block" id="{$config.config_name}">
                                                <input type="hidden" name="{$config.config_name}" id="inputimgurl{$config.config_name}" value="{$config.value? $config.value : ''}" >
                                                <div class="layui-input-inline">

                                                    {if condition="$config.value!=''&&$config.value!=null"}

                                                    &nbsp<img src="{$config.files.src}" id="srcimgurl{$config.config_name}" class="layui-upload-img" width="94" height="94" onclick="openimgs(this)">
                                                    {else /}

                                                    &nbsp<img src="/layui/images/image.png" id="srcimgurl{$config.config_name}" class="layui-upload-img" width="94" height="94" onclick="openimgs(this)">
                                                    {/if}


                                                </div>
                                                <div class="layui-input-block">
                                                    <button class="layui-btn layui-btn-warm" type="button" id="uploadimg{$config.config_name}">原图上传</button >
                                                    <button class="layui-btn layui-btn-normal" type="button" id="editimg{$config.config_name}">裁剪上传</button >
                                                    <button class="layui-btn layui-btn-danger" type="button" id="deleteimg{$config.config_name}">删除图片</button >
                                                </div>




                                            </div>
                                        </div>
                                        <div class="layui-col-md5">
                                            <div class="layui-input-block" >
                                                {$config.label_name}
                                            </div>
                                        </div>

                                    </div>
                                    <script>

                                        layui.use(['jquery','layer','form','upload','croppers'],function() {
                                            var $ = layui.jquery,
                                                layer = layui.layer
                                                 ,form = layui.form
                                                ,upload = layui.upload
                                                ,croppers{$config.config_name} = layui.croppers;
                                            $(function(){
                                                var tips;
                                                $('#{$config.config_name}').on({
                                                    mouseenter:function(){
                                                        var that = this;
                                                        tips =layer.tips("{$config.desc}",that,{tips:[1,'#5FB878'],time:0,area: 'auto'});
                                                    },
                                                    mouseleave:function(){
                                                        layer.close(tips);
                                                    }
                                                });
                                            })

                                            //创建一个头像上传组件
                                            croppers{$config.config_name}.render({
                                                elem: '#editimg{$config.config_name}'
                                                // ,saveW:600     //保存宽度
                                                // ,saveH:650
                                                //,mark:1/1    //选取比例
                                                ,area:'900px'  //弹窗宽度
                                                ,class_index:'{$config.config_name}'//弹层唯一标识
                                                ,url: "/manage/publicCommon/upload"  //图片上传接口返回和（layui 的upload 模块）返回的JOSN一样
                                                ,done: function(url,file){ //上传完毕回调
                                                    console.log(file);
                                                    $("#inputimgurl{$config.config_name}").val(JSON.stringify(file));
                                                    $("#srcimgurl{$config.config_name}").attr('src',url);
                                                }
                                            });
                                            var uploadimg{$config.config_name};
                                            //普通上传
                                            var uploadInst = upload.render({
                                                elem: '#uploadimg{$config.config_name}'
                                                ,url: "/manage/publicCommon/upload" //改成您自己的上传接口
                                                ,before: function(obj){
                                                    //预读本地文件示例，不支持ie8
                                                    obj.preview(function(index, file, result){
                                                        uploadimg{$config.config_name} = {
                                                            name: file.name,//原文件名
                                                            size: file.size,//大小
                                                            type: file.type,//文件类型
                                                        };
                                                    });
                                                }
                                                ,done: function(res){
                                                    //如果上传失败
                                                    if(res.data.errcode > 0){
                                                        return  layer.msg(res.msg, {
                                                            icon: 5,
                                                            time: 1000 //1.5秒关闭（如果不配置，默认是3秒）
                                                        });
                                                    }
                                                    //上传成功
                                                    uploadimg{$config.config_name}.src = res.data.data.src;
                                                    $("#inputimgurl{$config.config_name}").val(JSON.stringify(uploadimg{$config.config_name}));
                                                    $("#srcimgurl{$config.config_name}").attr('src', res.data.data.src);
                                                      layer.msg(res.msg, {
                                                        icon: 6,
                                                        time: 1000 //1.5秒关闭（如果不配置，默认是3秒）
                                                    });
                                                }
                                                ,error: function(){
                                                    //演示失败状态，并实现重传
                                                    return  layer.msg('上传失败', {
                                                        icon: 5,
                                                        time: 1000 //1.5秒关闭（如果不配置，默认是3秒）
                                                    });
                                                }
                                            });


                                        $('#deleteimg{$config.config_name}').on('click', function(){
                                            $("#inputimgurl{$config.config_name}").val('');
                                            $("#srcimgurl{$config.config_name}").attr('src','/layui/images/image.png');
                                        });
                                        })

                                        function openimgs(that) {
                                            //页面层-图片
                                            layer.open({
                                                type: 1,
                                                title: false,
                                                closeBtn: 0,
                                                area: ['auto'],
                                                skin: 'layui-layer-nobg', //没有背景色
                                                shadeClose: true,
                                                content: '<img  src="'+that.getAttribute('src')+'">'
                                            });

                                        }

                                    </script>


                                           {/case}
                                           {case value="2"}
                                             <!--多图-->
                                    <div class="layui-form-item">
                                        <div class="layui-col-md7">
                                            <label class="layui-form-label" >{$config.info}</label>
                                            <div class="layui-input-block" id="{$config.config_name}">

                                                <div class="layui-upload">
                                                    <button type="button" class="layui-btn layui-btn-normal" id="testList{$config.config_name}">选择多图</button>
                                                    <div class="layui-upload-list">
                                                        <table class="layui-table">
                                                            <thead>
                                                            <tr>
                                                                <th>浏览</th>
                                                                <th>文件名</th>
                                                                <th>大小</th>
                                                                <th>状态</th>
                                                                <th>操作</th>
                                                            </tr></thead>
                                                            <tbody id="demoList{$config.config_name}">
                                                            {volist name="config.files" id="file" key="fileindex"}

                                                            <tr id="upload-{$config.config_name}-{$fileindex}">
                                                                <td><img name="imgZmList" src="{$file.src}"width="100%" height="100" onclick="openimgs(this)"></td>
                                                                <td>{$file.name}</td>
                                                                <td><?php echo $file['size'] /1024 ?>kb</td>
                                                                <td><span style="color: #5FB878;">上传成功</span></td>
                                                                <td>
                                                                    <button class="layui-btn layui-btn-xs demo-reload layui-hide">重传</button>
                                                                    <button class="layui-btn layui-btn-xs layui-btn-danger demo-delete" type="button" data-filename="{$file.name}" onclick="deletefile{$config.config_name}(this,'upload-{$config.config_name}-{$fileindex}')" >删除</button>
                                                                    </td>
                                                            </tr>
                                                            {/volist}
                                                            </tbody>
                                                        </table>
                                                    </div>
                                                    <button type="button" class="layui-btn" id="testListAction{$config.config_name}">开始上传</button>
                                                    <input type="hidden" id="m_upload_{$config.config_name}" name="{$config.config_name}" value="{$config.value? $config.value : null}"/>
                                                </div>


                                            </div>
                                        </div>
                                        <div class="layui-col-md5">
                                            <div class="layui-input-block" >
                                                {$config.label_name}
                                            </div>
                                        </div>

                                    </div>


                                    <script>

                                        // var persons = [
                                        //     {name: "tina", age: 14},
                                        //     {name: "timo", age: 15},
                                        //     {name: "lily", age: 16},
                                        //     {name: "lucy", age: 16}
                                        // ];
                                        // JSON.stringify().

                                        layui.use(['jquery','layer','upload'],function() {
                                            var $ = layui.jquery,
                                                layer = layui.layer,
                                                upload = layui.upload;
                                                // cropper = layui.cropper,
                                                // croppers = layui.croppers;
                                            $(function(){
                                                var tips;
                                                $('#{$config.config_name}').on({
                                                    mouseenter:function(){
                                                        var that = this;
                                                        tips =layer.tips("{$config.desc}",that,{tips:[1,'#5FB878'],time:0,area: 'auto'});
                                                    },
                                                    mouseleave:function(){
                                                        layer.close(tips);
                                                    }
                                                });
                                            })

                                            //证明多图片上传
                                            //多文件列表示例
                                            var demoListView{$config.config_name} = $('#demoList{$config.config_name}')
                                                ,uploadListIns = upload.render({
                                                elem: '#testList{$config.config_name}'
                                                ,url: "/manage/publicCommon/upload" //改成您自己的上传接口
                                                ,accept: 'images'
                                                ,multiple: true
                                                ,auto: false
                                                ,bindAction: '#testListAction{$config.config_name}'
                                                ,choose: function(obj){
                                                    var files = this.files = obj.pushFile(); //将每次选择的文件追加到文件队列
                                                    //读取本地文件
                                                    obj.preview(function(index, file, result){
                                                        console.log(file);
                                                        var tr = $(['<tr id="upload-'+ index +'">'
                                                            ,'<td><img name="imgZmList" src="'+ result +'"width="100%" height="100" onclick="openimgs(this)"></td>'
                                                            ,'<td>'+ file.name +'</td>'
                                                            ,'<td>'+ (file.size/1024).toFixed(1) +'kb</td>'
                                                            ,'<td>等待上传</td>'
                                                            ,'<td>'
                                                            ,'<button class="layui-btn layui-btn-xs demo-reload layui-hide">重传</button>'
                                                            ,'<button class="layui-btn layui-btn-xs layui-btn-danger demo-delete" data-filename="'+file.name+'" >删除</button>'
                                                            ,'</td>'
                                                            ,'</tr>'].join(''));

                                                        //单个重传
                                                        tr.find('.demo-reload').on('click', function(){
                                                            obj.upload(index, file);
                                                        });

                                                        //删除
                                                        tr.find('.demo-delete').on('click', function(){
                                                          var filename = $(this).attr("data-filename");
                                                          //执行删除逻辑
                                                          if(filename){
                                                              var m_upload_{$config.config_name} = $('#m_upload_{$config.config_name}').val();
                                                              if(m_upload_{$config.config_name} != ''&&m_upload_{$config.config_name} != '[]'){
                                                                  m_upload_{$config.config_name} = JSON.parse(m_upload_{$config.config_name});
                                                                  let arr1=[];
                                                                  for(let i in m_upload_{$config.config_name}){
                                                                      arr1.push(m_upload_{$config.config_name}[i]);
                                                                  }
                                                                  m_upload_{$config.config_name} = arr1;

                                                              }else{
                                                                  m_upload_{$config.config_name} = new Array();
                                                              }

                                                              for (i = 0; i < m_upload_{$config.config_name}.length; i++) {
                                                                  var file  =  m_upload_{$config.config_name}[i];
                                                                 if(file.name==filename) m_upload_{$config.config_name}.splice(i,1);
                                                              }
                                                              $('#m_upload_{$config.config_name}').val(JSON.stringify(m_upload_{$config.config_name}));

                                                          }
                                                            console.log();
                                                            delete files[index]; //删除对应的文件
                                                            tr.remove();
                                                            uploadListIns.config.elem.next()[0].value = ''; //清空 input file 值，以免删除后出现同名文件不可选
                                                        });

                                                        demoListView{$config.config_name}.append(tr);
                                                    });
                                                }
                                                ,done: function(res, index, upload){

                                                    if(res.data.errcode==0){ //上传成功
                                                        layer.msg(res.msg, {
                                                            icon: 6,
                                                            time: 1000 //1.5秒关闭（如果不配置，默认是3秒）
                                                        });
                                                        var tr = demoListView{$config.config_name}.find('tr#upload-'+ index)
                                                            ,tds = tr.children();
                                                        tds.eq(3).html('<span style="color: #5FB878;">上传成功</span>');
                                                        // tds.eq(4).find('.demo-reload').removeClass('layui-hide'); //显示重传
                                                        //取出input框的值

                                                         var m_upload_{$config.config_name} = $('#m_upload_{$config.config_name}').val();
                                                        if(m_upload_{$config.config_name} != ''&&m_upload_{$config.config_name} != '[]'){
                                                            m_upload_{$config.config_name} = JSON.parse(m_upload_{$config.config_name});
                                                            let arr1=[];
                                                            for(let i in m_upload_{$config.config_name}){
                                                                arr1.push(m_upload_{$config.config_name}[i]);
                                                            }
                                                            m_upload_{$config.config_name} = arr1;

                                                        }else{
                                                            m_upload_{$config.config_name} = new Array();
                                                        }
                                                        var file = this.files[index];//得到文件相关信息
                                                        //追加值
                                                       var rs = {
                                                           name: file.name,//原文件名
                                                           src: res.data.data.src,//目标文件url
                                                           size: file.size,//大小
                                                           type: file.type,//文件类型
                                                       };
                                                        m_upload_{$config.config_name}.push(rs);

                                                        $('#m_upload_{$config.config_name}').val(JSON.stringify(m_upload_{$config.config_name}));
                                                        return delete this.files[index]; //删除文件队列已经上传成功的文件
                                                       // return  this.files.splice(index,1);
                                                        //return true; //删除文件队列已经上传成功的文件
                                                    }
                                                    layer.msg(res.msg, {
                                                        icon: 5,
                                                        time: 1000 //1.5秒关闭（如果不配置，默认是3秒）
                                                    });
                                                    this.error(index, upload);

                                                }
                                                ,error: function(index, upload){
                                                    var tr = demoListView{$config.config_name}.find('tr#upload-'+ index)
                                                        ,tds = tr.children();
                                                    tds.eq(3).html('<span style="color: #FF5722;">上传失败</span>');
                                                    // tds.eq(4).find('.demo-reload').removeClass('layui-hide'); //显示重传
                                                }
                                            });

                                        })

                                      function  deletefile{$config.config_name}(that,id){
                                          var filename = $(that).attr("data-filename");
                                          console.log(filename);
                                          //执行删除逻辑
                                          if(filename){
                                              var m_upload_{$config.config_name} = $('#m_upload_{$config.config_name}').val();
                                              if(m_upload_{$config.config_name} != ''&&m_upload_{$config.config_name} != '[]'){
                                                  m_upload_{$config.config_name} = JSON.parse(m_upload_{$config.config_name});
                                                  let arr1=[];
                                                  for(let i in m_upload_{$config.config_name}){
                                                      arr1.push(m_upload_{$config.config_name}[i]);
                                                  }
                                                  m_upload_{$config.config_name} = arr1;

                                              }else{
                                                  m_upload_{$config.config_name} = new Array();
                                              }

                                              for (i = 0; i < m_upload_{$config.config_name}.length; i++) {
                                                  var file  =  m_upload_{$config.config_name}[i];
                                                  if(file.name==filename) m_upload_{$config.config_name}.splice(i,1);
                                              }
                                              $('#m_upload_{$config.config_name}').val(JSON.stringify(m_upload_{$config.config_name}));

                                          }
                                          $("#"+id).remove();

                                        }


                                        function openimgs(that) {
                                            //页面层-图片
                                            layer.open({
                                                type: 1,
                                                title: false,
                                                closeBtn: 0,
                                                area: ['auto'],
                                                skin: 'layui-layer-nobg', //没有背景色
                                                shadeClose: true,
                                                content: '<img  src="'+that.getAttribute('src')+'">'
                                            });

                                        }

                                    </script>



                                           {/case}
                                           {case value="3"}
                                             <!--文件-->
                                    <div class="layui-form-item">
                                        <div class="layui-col-md7">
                                            <label class="layui-form-label" >{$config.info}</label>
                                            <div class="layui-input-block" id="{$config.config_name}">
                                                <div class="layui-upload">
                                                    <input type="hidden" name="{$config.config_name}" id="inputfileurl{$config.config_name}" value="{$config.value? $config.value : ''}" >

                                                    {if condition="$config.value!=''&&$config.value!=null"}

                                                    &nbsp&nbsp<span  id="uploadfilevent{$config.config_name}" style="color: #4b646f">{$config.files.name}</span>

                                                    {else /}

                                                    &nbsp&nbsp<span  id="uploadfilevent{$config.config_name}" style="color: #4b646f">未选择文件</span>

                                                    {/if}


                                                    <button type="button" class="layui-btn layui-btn-normal" id="uploadfileselect{$config.config_name}">选择文件</button>

                                                    <button type="button" class="layui-btn" id="uploadfilesend{$config.config_name}">开始上传</button>
                                                    <button class="layui-btn layui-btn-danger" type="button" id="deletefile{$config.config_name}">删除文件</button >
                                                </div>



                                            </div>
                                        </div>
                                        <div class="layui-col-md5">
                                            <div class="layui-input-block" >
                                                {$config.label_name}
                                            </div>
                                        </div>

                                    </div>
                                    <script>

                                        layui.use(['jquery','layer','upload'],function() {
                                            var $ = layui.jquery,
                                                layer = layui.layer,
                                                upload = layui.upload;
                                            $(function(){
                                                var tips;
                                                $('#{$config.config_name}').on({
                                                    mouseenter:function(){
                                                        var that = this;
                                                        tips =layer.tips("{$config.desc}",that,{tips:[1,'#5FB878'],time:0,area: 'auto'});
                                                    },
                                                    mouseleave:function(){
                                                        layer.close(tips);
                                                    }
                                                });
                                            })

                                            var uploadfile{$config.config_name};
                                            //选完文件后不自动上传
                                            upload.render({
                                                elem: '#uploadfileselect{$config.config_name}'
                                                ,url: "{:Url('/manage/publicCommon/upload',['rule'=>'fileExt:jpg,jpeg,png,gif,pem,sql,txt,html,js,css,php'])}" //改成您自己的上传接口
                                                ,auto: false
                                                ,accept:'file'//允许上传的文件类型
                                                //,multiple: true
                                                ,bindAction: '#uploadfilesend{$config.config_name}'
                                                ,choose: function(obj){
                                                    // this.files =[];
                                                    // //将每次选择的文件追加到文件队列
                                                    // var files = this.files = obj.pushFile();
                                                    //预读本地文件，如果是多文件，则会遍历。(不支持ie8/9)
                                                    obj.preview(function(index, file, result){
                                                        console.log(index); //得到文件索引
                                                        console.log(file); //得到文件对象
                                                        console.log(result); //得到文件base64编码，比如图片
                                                        $('#uploadfilevent{$config.config_name}').html(file.name);

                                                        uploadfile{$config.config_name} = {
                                                            name: file.name,//原文件名
                                                            size: file.size,//大小
                                                            type: file.type,//文件类型
                                                        };
                                                        //obj.resetFile(index, file, '123.jpg'); //重命名文件名，layui 2.3.0 开始新增

                                                        //这里还可以做一些 append 文件列表 DOM 的操作

                                                        //obj.upload(index, file); //对上传失败的单个文件重新上传，一般在某个事件中使用
                                                        //delete files[index]; //删除列表中对应的文件，一般在某个事件中使用
                                                    });
                                                }
                                                ,done: function(res, index, upload){
                                                    //如果上传失败
                                                    if(res.data.errcode > 0){
                                                        return  layer.msg(res.msg, {
                                                            icon: 5,
                                                            time: 1000 //1.5秒关闭（如果不配置，默认是3秒）
                                                        });
                                                    }
                                                    //上传成功
                                                    uploadfile{$config.config_name}.src = res.data.data.src;
                                                    $("#inputfileurl{$config.config_name}").val(JSON.stringify(uploadfile{$config.config_name}));
                                                    layer.msg(res.msg, {
                                                        icon: 6,
                                                        time: 1000 //1.5秒关闭（如果不配置，默认是3秒）
                                                    });
                                                    return delete this.files[index]; //删除文件队列已经上传成功的文件
                                                }
                                                ,error: function(){
                                                    //演示失败状态，并实现重传
                                                    return  layer.msg('上传失败', {
                                                        icon: 5,
                                                        time: 1000 //1.5秒关闭（如果不配置，默认是3秒）
                                                    });
                                                }
                                            });
                                            $('#deletefile{$config.config_name}').on('click', function(){
                                                $('#uploadfilevent{$config.config_name}').html('未选择文件');
                                                $("#inputfileurl{$config.config_name}").val('');
                                            });
                                        })

                                    </script>

                                           {/case}
                                       {/switch}


                                    {/case}

                                    {default /}
                                    {/switch}
                                        <!--生成表单   end-->
                                    <!--<hr class="layui-bg-blue">-->
                                    {/volist}

                                </div>
                                {/volist}


                            </div>

                        </div>





                    </div>
                </div>
            </div>
        </div>










    <button type="button" class="layui-btn layui-btn-fluid layui-btn-normal" lay-submit="" lay-filter="formDemo">更新配置</button>



</form>

{/block}

{block name="js"}

<script>

    var table;
    var laydate;
    var	$;
    var form;
    var tab_type='text';
    layui.use(['form', 'table','util','laydate','layer','element'],function() {
        $ = layui.jquery;
        var util = layui.util,layer = layui.layer ,element = layui.element;
        table = layui.table;
        form = layui.form;
        laydate = layui.laydate;
        form.render();

        form.on('submit(formDemo)', function (data) {

               // console.log(typeof data.field);
            $.ajax({
                url:"{:Url('setValues')}",
                type:'post',
                data:data.field,
                dataType: "json", contentType: "application/x-www-form-urlencoded; charset=utf-8",
                success:function(data){
                     console.log(typeof data)
                    if(data.data.errcode == 0){
                        layer.msg('处理中...',{shade:[0.8, '#393D49'],time:60*60*2000});
                        layer.msg('修改成功', {
                            icon: 6,
                            time: 1000 //1.5秒关闭（如果不配置，默认是3秒）
                        });
                    }else if(data.errcode != 0){
                        layer.msg(data.msg, {
                            icon: 5,
                            time: 1500 //1.5秒关闭（如果不配置，默认是3秒）
                        });

                    }else{
                        layer.msg('操作失败！请稍后再试。', {
                            icon: 5,
                            time: 1500 //1.5秒关闭（如果不配置，默认是3秒）
                        });

                    }
                },
                error:function(e){
                    layer.alert("提交失败！")
                },

            });
            return false;
        });



        // //触发tab事件
        element.on('tab(docDemoTabBrief)', function(elem){
            // location.hash = 'test='+ $(this).attr('lay-id');

            //tab切换下标事件
            tab_type = getType(elem.index);

               // var i  =getIndex("{$entity.type? $entity.type : 'text'}");

                // $(".layui-tab-title li").removeClass("layui-this");
                // $(".layui-tab-content .layui-tab-item").removeClass("layui-show");
                // $(".layui-tab-title li:eq("+elem.index+")").addClass("layui-this");
                // $(".layui-tab-content .layui-tab-item:eq("+elem.index+")").addClass("layui-show");
        });


    })






    function getIndex(type) {
        var rs=0;
        switch(type) {
            case 'text':
                rs=0;
                break;
            case 'textarea':
                rs=1;
                break;
            case 'r_textarea':
                rs=2;
                break;
            case 'radio':
                rs=3;
                break;
            case 'checkbox':
                rs=4;
                break;
            case 'select':
                rs=5;
                break;
            case 'upload':
                rs=6;
                break;
        }
        return rs;
    }

    function getType(index) {
        var rs='text';
        switch(index) {
            case 0:
                rs='text';
                break;
            case 1:
                rs='textarea';
                break;
            case 2:
                rs='r_textarea';
                break;
            case 3:
                rs='radio';
                break;
            case 4:
                rs='checkbox';
                break;
            case 5:
                rs='select';
                break;
            case 6:
                rs='upload';
                break;
        }
        return rs;
    }

    function HTMLDecode(text)
    {
        var temp = document.createElement("div");
        temp.innerHTML = text;
        var output = temp.innerText || temp.textContent;
        temp = null;
        return output;
    }

    /**
     * 富文本编码
     * @param text
     * @returns {string}
     */
    function r_text_encode(text)
    {
        return window.btoa(window.encodeURIComponent(text))
    }

    /**
     * 富文本解码
     * @param text
     * @returns {string}
     */
    function r_text_decode(text)
    {
        return window.decodeURIComponent(window.atob(text))
    }

</script>
{/block}